package cn.tedu.submarine;

import javax.swing.*;

public class Battleship extends SeaObject {//战舰
    private int life;
    public Battleship(){
        super(66,26,270,124,20);
        life = 5;
    }
    public void move(){

    }
    public void moveLeft(){
        if (getX() >= 0) {
            setX(getX()-getSpeed());
        }
    }
    public void moveRight(){
        if (getX() <= World.WIDTH) {
            setX(getX()+getSpeed());
        }
    }
    /**  重写*/
    public  ImageIcon getImage(){
        return Images.battleship;
    }
    /** 战舰发射炸弹  */
    public Bomb shootBomb(){
        return new Bomb(this.getX(),this.getY());//this指的是战舰当前的坐标
    }
    /** 战舰增命 */
    public void addLife(int num){
        life += num; //增加 num 命
    }


    /** 获取命数 */
    public int getLife() {
        return life;
    }
    /** 战舰减命 */
    public void subtractLife(){
        life--;//命减一
    }
}
